package com.tedu._04mybatis.mapper;

import com.tedu._04mybatis.pojo.Comment;
import com.tedu._04mybatis.pojo.CommentVO1;
import com.tedu._04mybatis.pojo.CommentVO2;
import com.tedu._04mybatis.pojo.Weibo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {
    /*
    @Insert("INSERT INTO comment(content,created,user_id,weibo_id) " +
            "VALUES (#{content},#{created},#{userId},#{weiboId}) ")
     */

    int insertComment(Comment comment);

    /*
    @Delete("DELETE FROM comment "+
            "WHERE id=#{id}")
     */

    int deleteCommentById(Integer id);

    /*
    @Update("UPDATE comment "+
            "SET content=#{content},created=#{created},user_id=#{userId},weibo_id=#{weiboId} " +
            "WHERE id=#{id}")
     */

    int updateComment(Comment comment);

    /*
    @Select("SELECT content,user_id AS userId,weibo_id AS weiboId " +
            "FROM comment " +
            "WHERE id=#{id}")
     */

    CommentVO2 selectCommentVO2ById(Integer id);

    /*
    @Select("SELECT c.content,c.user_id AS userId " +
            "FROM comment c " +
            "JOIN weibo w ON w.id = c.weibo_id "+
            "WHERE w.id = #{w.id}")
     */

    List<CommentVO1> selectCommentVO1ById(Integer id);
}
